<?php
class Mhome extends Model {
        function Mhome() {
			parent::Model();
        }


		
		//根据最新时间查询出最后一个表单的id号
		function last_id(){
			$sql="select id from info order by id asc";
            $query=$this->db->query($sql);
            $row = $query->last_row();
			return $row->id;
		}
		function insert_info($req) {
			$query=$this->db->insert('info',$req);
			//返回一个影响的结果集
			return $this->db->affected_rows();
        }

		//更新［修改］数据
		function update_modify($data,$id){
			$this->db->update('info', $data, "id = $id");
			return $this->db->affected_rows();
		}

		function list_info($id){
			$sql="select * from info where id=$id";
            $query=$this->db->query($sql);
			return $query->result();
		}



		//list.php这个列表页面，需要分页
        function list_tips($start,$offset) {
			$sql="select id,othername,creattime,rubbish from info order by creattime desc limit $start,$offset";
            $query=$this->db->query($sql);
			return $query->result();
        }

		function list_tips_total(){
			$sql="select sum(id!=0) as total from info";
            $query=$this->db->query($sql);
			return $query->result();
		}

		//垃圾订单与正常订单切换
		function chang_rubbish($id){
			$sql="UPDATE `info` SET `rubbish`='1' WHERE (`id`='$id')";
            $query=$this->db->query($sql);
			return $this->db->affected_rows();
		}
		//垃圾订单转化为正常订单
		function chang_nomal($id){
			$sql="UPDATE `info` SET `rubbish`='0' WHERE (`id`='$id')";
            $query=$this->db->query($sql);
			return $this->db->affected_rows();
		}



}//end mhome.mode
?>